<?php
/***************************************************************
*  Copyright notice
*  (c) 2008, jianyuzhu@gmail.com
*  All rights reserved
*  This script is part of the PPEMI project.
***************************************************************/

//
set_time_limit(0);

//
require(dirname(dirname(__FILE__)) . '/includes/application_top.php');

//
include_once(CONFIG_PATH . CONFIG_DIR_INCLUDES . 'functions/thumb.function.php');
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.directory.class.php');
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.upload.class.php');
include_once(CONFIG_PATH . CONFIG_DIR_CLASSES . 'core.file.class.php');
include_once(CONFIG_PATH . CONFIG_DIR_FUNCTIONS . 'thumb.function.php');

//
$dirs = array('1' => 'tour2005/', '2' => 'rehearsals/', '3' => 'outings/');

//
foreach($dirs as $aid => $dir) {
	//
	echo '<hr>';
	//
	$dObj = new CoreDirectoryParser(CONFIG_PATH . CONFIG_DIR_UPLOADS_ORIGINS . $dir);
	$dObj->parse();
	$_dir = $dObj->_dir;
	$files = $dObj->getFiles();
	//
	if( is_array($files) ) {
		foreach($files as $key => $file) {
			$upload_file = CONFIG_PATH . CONFIG_DIR_UPLOADS_RESIZED . $dir . $file['file'];
			
			$upload_fileObj = new CoreFile($upload_file);
			$upload_fileObj->parse();
			
			if( $upload_fileObj->is_image == true ) {
				$image_attribute = $upload_fileObj->getFileAttribute();
				$image_width = $upload_fileObj->getImageWidth();
				$image_height = $upload_fileObj->getImageHeight();
				//
				$query = "update pp_galleries_images set images_width = '" . $image_width . "', images_height = '" . $image_height . "' ";
				$query .= " where images_aid = '" . $aid . "' and images_value = '" . $dir . $file['file'] . "'";
				//
				echo $query;
				$adb->update($query);
				//
				echo '<br>';
			}
		}
	}
}//
//
echo 'OK';
//
?>